//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类.demo1AND20;

public class demo11 {
    public demo11() {
    }

    public static void main(String[] args) {
        int[] height = new int[]{8, 7, 2, 1};
        System.out.println(maxArea(height));
    }

    public static int maxArea(int[] height) {
        int max = 0;
        int i = 0;
        int j = height.length - 1;

        while(i < j) {
            int mid = Math.min(height[i], height[j]);

            for(max = Math.max(max, (j - i) * Math.min(height[j], height[i])); height[i] <= mid && i < j; ++i) {
            }

            while(height[j] <= mid && i < j) {
                --j;
            }
        }

        return max;
    }
}
